package com.jwgf.smarowindingmachine_unity.ui;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.jwgf.Half485.fxthreadpool.FxPLCData;
import com.jwgf.Half485.modbusthreadpool.ModbusCommandManager;
import com.jwgf.Half485.modbusthreadpool.PLCData;
import com.jwgf.common.ViewCache;
import com.jwgf.smarowindingmachine_unity.R;
import com.jwgf.smarowindingmachine_unity.logic.CommandGenerator;
import com.jwgf.smarowindingmachine_unity.logic.MachineParameterSharedPreference;
import com.jwgf.smarowindingmachine_unity.logic.SmaroWindingMachineDataAccessRules;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class ParameterSettingCbfParameterFragment extends BaseFragment
        implements OnFocusChangeListener, OnEditorActionListener, OnClickListener {
    public static final String fragmentTag = "ParameterSettingCbfParameterFragment";

    private MachineParameterSharedPreference sp = MachineParameterSharedPreference.getInstance();

    private EditText forfex_time_edit;            //D0407
    private EditText operation_time_edit;        //D0403
    private EditText draught_open_time_edit;        //D0404
    private EditText bellows_drop_time_edit;        //D0406
    private EditText thrum_suck_num_edit;        //D0405
    private EditText cop_vent_num_edit;            //D0408
    private EditText insert_bobbin_time_edit;            //D0412

    private TextView presser_bar_motion_value;    //D0402
    private TextView motor_direction_value;        //D0400
    private TextView full_package_handle_value;    //D0401
    private TextView category_value;                //D0409
    private TextView failed_channel_full_process_value;

    private ImageButton presser_bar_motion_btn;
    private ImageButton motor_direction_btn;
    private ImageButton full_package_handle_btn;
    private ImageButton category_btn;
    private ImageButton failed_channel_full_process_btn;

    private RelativeLayout insert_bobbin_time_layout;
    private RelativeLayout motor_direction_layout;
    private RelativeLayout failed_channel_full_process_layout;

    private View thisView = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = ViewCache.getInstance().getView(R.layout.fragment_parameter_setting_cbf_parameter);
        thisView = v;
        initialViews(thisView);
        EventBus.getDefault().register(this);
        updateViews();
        return v;
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            EventBus.getDefault().unregister(this);
        } else {
            updateViews();
            EventBus.getDefault().register(this);
        }
    }

    private void initialViews(View v) {
        forfex_time_edit = initEdittextOnCreate(R.id.forfex_time_value);
        operation_time_edit = initEdittextOnCreate(R.id.operation_time_value);
        draught_open_time_edit = initEdittextOnCreate(R.id.draught_open_time_value);
        bellows_drop_time_edit = initEdittextOnCreate(R.id.bellows_drop_time_value);
        thrum_suck_num_edit = initEdittextOnCreate(R.id.thrum_suck_num_value);
        cop_vent_num_edit = initEdittextOnCreate(R.id.cop_vent_num_value);
        insert_bobbin_time_edit = initEdittextOnCreate(R.id.insert_bobbin_time_value);

        insert_bobbin_time_layout = thisView.findViewById(R.id.insert_bobbin_time_layout);
        motor_direction_layout = thisView.findViewById(R.id.motor_direction_layout);
        failed_channel_full_process_layout = thisView.findViewById(R.id.failed_channel_full_process_layout);

        presser_bar_motion_btn = (ImageButton) v.findViewById(R.id.presser_bar_motion_btn);
        presser_bar_motion_btn.setOnClickListener(this);
        motor_direction_btn = (ImageButton) v.findViewById(R.id.motor_direction_btn);
        motor_direction_btn.setOnClickListener(this);
        full_package_handle_btn = (ImageButton) v.findViewById(R.id.full_package_handle_btn);
        full_package_handle_btn.setOnClickListener(this);
        category_btn = (ImageButton) v.findViewById(R.id.category_btn);
        category_btn.setOnClickListener(this);
        failed_channel_full_process_btn = v.findViewById(R.id.failed_channel_full_process_btn);
        failed_channel_full_process_btn.setOnClickListener(this);

        presser_bar_motion_value = (TextView) v.findViewById(R.id.presser_bar_motion_value);
        motor_direction_value = (TextView) v.findViewById(R.id.motor_direction_value);
        full_package_handle_value = (TextView) v.findViewById(R.id.full_package_handle_value);
        category_value = (TextView) v.findViewById(R.id.category_value);
        failed_channel_full_process_value = v.findViewById(R.id.failed_channel_full_process_value);
    }

    private EditText initEdittextOnCreate(int id) {
        EditText editText = (EditText) thisView.findViewById(id);
        editText.setSelectAllOnFocus(true);
        editText.setOnFocusChangeListener(this);
        editText.setOnEditorActionListener(this);
        editText.setBackgroundDrawable(null);
        return editText;
    }

    private void updateViews() {
        forfex_time_edit.setText(sp.getValue(MachineParameterSharedPreference.FORFEX_TIME, "8"));
        operation_time_edit.setText(sp.getValue(MachineParameterSharedPreference.OPERATION_TIME, "10"));
        draught_open_time_edit.setText(sp.getValue(MachineParameterSharedPreference.DRAUGHT_OPEN_TIME, "8"));
        bellows_drop_time_edit.setText(sp.getValue(MachineParameterSharedPreference.BELLOWS_DROP_TIME, "3"));
        thrum_suck_num_edit.setText(sp.getValue(MachineParameterSharedPreference.THRUM_SUCK_NUM, "2"));
        cop_vent_num_edit.setText(sp.getValue(MachineParameterSharedPreference.COP_VENT_NUM, "3"));
        insert_bobbin_time_edit.setText(sp.getValue(MachineParameterSharedPreference.TRANSMIT_TIME, "5"));

        if (sp.getValue(MachineParameterSharedPreference.PRESSER_BAR_MOTION, "0").equals("0")) {
            presser_bar_motion_value.setText(R.string.no_action);
        } else {
            presser_bar_motion_value.setText(R.string.have_action);
        }

        if (sp.getValue(MachineParameterSharedPreference.MOTOR_DIRECTION, "0").equals("0")) {
            motor_direction_value.setText(R.string.forward);
        } else {
            motor_direction_value.setText(R.string.reverse);
        }

        if (sp.getValue(MachineParameterSharedPreference.FULL_PACKAGE_HANDLE, "0").equals("0")) {
            full_package_handle_value.setText(R.string.not_pull);
        } else if (sp.getValue(MachineParameterSharedPreference.FULL_PACKAGE_HANDLE, "0").equals("1")) {
            full_package_handle_value.setText(R.string.full_all_pull);
        } else {
            full_package_handle_value.setText(R.string.no_repiece_pull);
        }

        if (sp.getValue(MachineParameterSharedPreference.CATEGORY, "0").equals("0")) {
            category_value.setText(R.string.end_category);
        } else {
            category_value.setText(R.string.start_category);
        }

        String[] failedChannelFullProcess = getResources().getStringArray(R.array.failed_channel_full_process);
        int index = Integer.valueOf(sp.getValue(MachineParameterSharedPreference.CATEGORY, "0"));
        failed_channel_full_process_value.setText(failedChannelFullProcess[index]);

        if (MachineParameterSharedPreference.getInstance().getValue(MachineParameterSharedPreference.MACHINE_MACHINE_TYPE, "0").equals("3")) {
            failed_channel_full_process_layout.setVisibility(View.VISIBLE);
        } else {
            failed_channel_full_process_layout.setVisibility(View.INVISIBLE);

        }

        if (MachineParameterSharedPreference.getInstance().getValue(MachineParameterSharedPreference.MACHINE_MACHINE_TYPE, "0").equals("5")
        ||MachineParameterSharedPreference.getInstance().getValue(MachineParameterSharedPreference.MACHINE_MACHINE_TYPE, "0").equals("2")) {
            insert_bobbin_time_layout.setVisibility(View.VISIBLE);
            motor_direction_layout.setVisibility(View.INVISIBLE);
        } else {
            insert_bobbin_time_layout.setVisibility(View.INVISIBLE);
            motor_direction_layout.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            String strValue = v.getText().toString();
            if (strValue.equals("")) {
                return false;
            }
            boolean isValid = false;
            String key = "";
            String valueString = v.getText().toString();
            byte[] datai = new byte[2];
            switch (v.getId()) {
                case R.id.forfex_time_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.FORFEX_TIME, strValue);
                    key = MachineParameterSharedPreference.FORFEX_TIME;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 50, datai));//407
                        sp.setValue(key, valueString);
                    }
                    break;

                case R.id.operation_time_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.OPERATION_TIME, strValue);
                    key = MachineParameterSharedPreference.OPERATION_TIME;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 51, datai));//403
                        sp.setValue(key, valueString);
                    }
                    break;

                case R.id.draught_open_time_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.DRAUGHT_OPEN_TIME, strValue);
                    key = MachineParameterSharedPreference.DRAUGHT_OPEN_TIME;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 52, datai));//404
                        sp.setValue(key, valueString);
                    }
                    break;
                case R.id.bellows_drop_time_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.BELLOWS_DROP_TIME, strValue);
                    key = MachineParameterSharedPreference.BELLOWS_DROP_TIME;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 53, datai));//406
                        sp.setValue(key, valueString);
                    }
                    break;

                case R.id.thrum_suck_num_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.THRUM_SUCK_NUM, strValue);
                    key = MachineParameterSharedPreference.THRUM_SUCK_NUM;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 54, datai));//405
                        sp.setValue(key, valueString);
                    }
                    break;

                case R.id.cop_vent_num_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.COP_VENT_NUM, strValue);
                    key = MachineParameterSharedPreference.COP_VENT_NUM;
                    if (isValid) {
                        int value = Integer.parseInt(valueString);
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 55, datai));//408
                        sp.setValue(key, valueString);
                    }
                    break;

                case R.id.insert_bobbin_time_value:
                    isValid = SmaroWindingMachineDataAccessRules.getInstance().isBetween(MachineParameterSharedPreference.TRANSMIT_TIME, strValue);
                    key = MachineParameterSharedPreference.TRANSMIT_TIME;
                    if (isValid) {
                        int value = Integer.parseInt(valueString) * 10;
                        datai[0] = (byte) ((value & 0xff00) >> 8);
                        datai[1] = (byte) (value & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommandList(
                                        (byte) 1, 100, datai));//412
                        sp.setValue(key, valueString);
                    }
                    break;

                default:
                    break;
            }
            if (!isValid) {
                String max = SmaroWindingMachineDataAccessRules.getInstance().getDataAccessRule(key).getMax();
                String min = SmaroWindingMachineDataAccessRules.getInstance().getDataAccessRule(key).getMin();
                String warning = getResources().getString(R.string.range_warning);
                warning = String.format(warning, min, max);
                WarningDialog.show(getActivity(), warning);
                updateViews();
            }

        }
        return false;
    }


    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        int id = v.getId();
        switch (id) {
            case R.id.forfex_time_value:
                if (!hasFocus) {
                    forfex_time_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.FORFEX_TIME, "8"));
                }
                break;
            case R.id.operation_time_value:
                if (!hasFocus) {
                    operation_time_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.OPERATION_TIME, "10"));
                }
                break;
            case R.id.draught_open_time_value:
                if (!hasFocus) {
                    draught_open_time_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.DRAUGHT_OPEN_TIME, "8"));
                }
                break;
            case R.id.bellows_drop_time_value:
                if (!hasFocus) {
                    bellows_drop_time_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.BELLOWS_DROP_TIME, "3"));
                }
                break;
            case R.id.thrum_suck_num_value:
                if (!hasFocus) {
                    thrum_suck_num_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.THRUM_SUCK_NUM, "2"));
                }
                break;
            case R.id.cop_vent_num_value:
                if (!hasFocus) {
                    cop_vent_num_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.COP_VENT_NUM, "3"));
                }
                break;
            case R.id.insert_bobbin_time_value:
                if (!hasFocus) {
                    insert_bobbin_time_edit.setText(
                            sp.getValue(MachineParameterSharedPreference.TRANSMIT_TIME, "5"));
                }
                break;
            default:
                break;
        }
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.presser_bar_motion_btn: {
                final String[] content = getResources().getStringArray(R.array.presser_bar_motion);
                ListDialogFragment listDialog = new ListDialogFragment();
                Bundle bd = new Bundle();
                bd.putStringArray(ListDialogFragment.ARRAY, content);
                listDialog.setArguments(bd);
                listDialog.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        presser_bar_motion_value.setText(content[position]);
                        byte[] datai = new byte[2];
                        datai[0] = (byte) ((position & 0xff00) >> 8);
                        datai[1] = (byte) (position & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 56, datai));//402
                        sp.setValue(MachineParameterSharedPreference.PRESSER_BAR_MOTION, String.valueOf(position));

                    }
                });
                listDialog.show(getFragmentManager(), "listDialog");
            }
            break;

            case R.id.motor_direction_btn: {
                final String[] content = getResources().getStringArray(R.array.motor_direction);
                ListDialogFragment listDialog = new ListDialogFragment();
                Bundle bd = new Bundle();
                bd.putStringArray(ListDialogFragment.ARRAY, content);
                listDialog.setArguments(bd);
                listDialog.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        motor_direction_value.setText(content[position]);
                        byte[] datai = new byte[2];
                        datai[0] = (byte) ((position & 0xff00) >> 8);
                        datai[1] = (byte) (position & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 57, datai));//400
                        sp.setValue(MachineParameterSharedPreference.MOTOR_DIRECTION, String.valueOf(position));
                    }
                });
                listDialog.show(getFragmentManager(), "listDialog");
            }
            break;

            case R.id.full_package_handle_btn: {
                final String[] content = getResources().getStringArray(R.array.full_package_handle);
                ListDialogFragment listDialog = new ListDialogFragment();
                Bundle bd = new Bundle();
                bd.putStringArray(ListDialogFragment.ARRAY, content);
                listDialog.setArguments(bd);
                listDialog.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        full_package_handle_value.setText(content[position]);
                        byte[] datai = new byte[2];
                        datai[0] = (byte) ((position & 0xff00) >> 8);
                        datai[1] = (byte) (position & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 58, datai));//401
                        sp.setValue(MachineParameterSharedPreference.FULL_PACKAGE_HANDLE, String.valueOf(position));
                    }
                });
                listDialog.show(getFragmentManager(), "listDialog");
            }
            break;

            case R.id.category_btn: {
                final String[] content = getResources().getStringArray(R.array.category);
                ListDialogFragment listDialog = new ListDialogFragment();
                Bundle bd = new Bundle();
                bd.putStringArray(ListDialogFragment.ARRAY, content);
                listDialog.setArguments(bd);
                listDialog.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        category_value.setText(content[position]);
                        byte[] datai = new byte[2];
                        datai[0] = (byte) ((position & 0xff00) >> 8);
                        datai[1] = (byte) (position & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 59, datai));//409
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 103, datai));//409
                        sp.setValue(MachineParameterSharedPreference.CATEGORY, String.valueOf(position));
                    }
                });
                listDialog.show(getFragmentManager(), "listDialog");
            }
            break;
            case R.id.failed_channel_full_process_btn: {
                final String[] content = getResources().getStringArray(R.array.failed_channel_full_process);
                ListDialogFragment listDialog = new ListDialogFragment();
                Bundle bd = new Bundle();
                bd.putStringArray(ListDialogFragment.ARRAY, content);
                listDialog.setArguments(bd);
                listDialog.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        failed_channel_full_process_value.setText(content[position]);
                        byte[] datai = new byte[2];
                        datai[0] = (byte) ((position & 0xff00) >> 8);
                        datai[1] = (byte) (position & 0xff);
                        ModbusCommandManager.getInstance()
                                .putPriorityCmd(CommandGenerator.createWriteCommand(
                                        (byte) 1, 79, datai));
                        sp.setValue(MachineParameterSharedPreference.FAILED_CHANNEL_FULL_PROCESS, String.valueOf(position));
                    }
                });
                listDialog.show(getFragmentManager(), "listDialog");
            }
            break;
            default:
                break;
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onHoldingRegisterEvent(PLCData.HoldingRegister holding) {
        int addr = holding.addr;
        int value = holding.value;
        switch (addr) {
            case 50:
                forfex_time_edit.setText(String.valueOf(value));
                break;
            case 51:
                operation_time_edit.setText(String.valueOf(value));
                break;
            case 52:
                draught_open_time_edit.setText(String.valueOf(value));
                break;
            case 53:
                bellows_drop_time_edit.setText(String.valueOf(value));
                break;
            case 54:
                thrum_suck_num_edit.setText(String.valueOf(value));
                break;
            case 55:
                cop_vent_num_edit.setText(String.valueOf(value));
                break;
            case 56: {
                String[] content = getResources().getStringArray(R.array.presser_bar_motion);
                presser_bar_motion_value.setText(content[value]);
            }
            break;
            case 57: {
                String[] content = getResources().getStringArray(R.array.motor_direction);
                motor_direction_value.setText(content[value]);
            }
            break;
            case 58: {
                String[] content = getResources().getStringArray(R.array.full_package_handle);
                full_package_handle_value.setText(content[value]);
            }
            break;
            case 59: {
                String[] content = getResources().getStringArray(R.array.category);
                category_value.setText(content[value]);
            }
            break;
            case 100:
                insert_bobbin_time_edit.setText(String.valueOf(value / 10));
                break;
            case 79: {
                String[] content = getResources().getStringArray(R.array.failed_channel_full_process);
                failed_channel_full_process_value.setText(content[value]);
            }
            break;
        }

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDRegisterEvent(FxPLCData.DRegister dRegister) {
        int addr = dRegister.fxPLCData.getKey(dRegister);
        int value = dRegister.value;
        switch (addr) {
            case (4 << 16 | 407):
                forfex_time_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 403):
                operation_time_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 404):
                draught_open_time_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 406):
                bellows_drop_time_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 405):
                thrum_suck_num_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 408):
                cop_vent_num_edit.setText(String.valueOf(value));
                break;
            case (4 << 16 | 402):
                final String[] content1 = getResources().getStringArray(R.array.presser_bar_motion);
                presser_bar_motion_value.setText(content1[value]);
                break;
            case (4 << 16 | 400):
                final String[] content2 = getResources().getStringArray(R.array.motor_direction);
                motor_direction_value.setText(content2[value]);
                break;
            case (4 << 16 | 401):
                final String[] content3 = getResources().getStringArray(R.array.full_package_handle);
                full_package_handle_value.setText(content3[value]);
                break;
            case (4 << 16 | 409):
                final String[] content = getResources().getStringArray(R.array.category);
                category_value.setText(content[value]);
                break;
            case (5 << 16 | 412):
                insert_bobbin_time_edit.setText(String.valueOf(value / 10));
                break;
        }

    }

}